package com.bw.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/***************************
 FileAction:

 CreateTime:2022-08-23 9:22
 Author:Aaking-aline
 ****************************/
public class SqlSessionFactoryUtil {

	private static SqlSessionFactory ssf = null;

	public static SqlSessionFactory getSqlSessionFactory() throws IOException {
		if(ssf == null){
			String resource = "mybatis-config.xml";
			InputStream is = Resources.getResourceAsStream(resource);
			SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
			ssf = factory;
		}

		return ssf;
	}
}
